Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Using the CAN-QUERY and CAN-SET functions
In this kind of code, where you are walking through a frame that might contain many different kinds of objects, you might need to verify not only whether the current object handle is valid, but also whether it is valid to set or query a particular attribute. If you don’t, you might get an error at run time. The code you’ve been looking at checks that an object is a fill-in before it checks the
DATA-TYPE, but suppose for a moment that the originalTYPEcheck wasn’t there:
When Progress tries to retrieve the
DATA-TYPEof an object that doesn’t have this attribute, such as the browse, you get the error shown in Figure 18–13.Figure 18–13: DATA-TYPE error message
![]()
To avoid this error, in cases where you can’t be sure whether the attribute matches the object type, you can use the
CAN-QUERYfunction to check whether something is a readable attribute before your code does so.CAN-QUERYtakes two arguments, a valid object handle and a character expression that evaluates to an attribute name. This code example eliminates the error:
Likewise, you can check in advance whether something is a writable attribute using the
CAN-SETfunction, which also takes an object handle and attribute name as arguments:
You’ll find these functions useful especially in cases where the attribute name itself is a variable, so that you can’t be sure when you write the code whether all possible values will be valid.
To see a list of all the valid attributes you can set or query for an object, use the
LIST-QUERY-ATTRSandLIST-SET-ATTRSfunctions. Each function takes a valid object handle as an argument:
As you can see in Figure 18–14, the list of attributes for most objects is quite large. You can find out about all of them in the online help and in OpenEdge Development: Progress 4GL Reference .
Figure 18–14: Result of LIST-QUERY-ATTRS function example
![]()
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |